package parameter

import (
	"gf-assistant/internal/common"
	"github.com/gogf/gf/v2/frame/g"
)

type GetUserReq struct {
	g.Meta `path:"/get" method:"post"`
	UserId int32 `p:"UserId"  d:"10024" v:"required#用户Id必填" dc:"成员ID"`
}

type GetUserRes struct {
	UserId           uint   `json:"userId" dc:"用户ID"`
	OrgId            uint   `json:"orgId" dc:"机构ID"`
	UserName         string `json:"userName" dc:"成员账号"`
	OrgName          string `json:"orgName" dc:"机构名称"`
	NickName         string `json:"nickName" dc:"成员昵称"`
	RoleNames        string `json:"roleNames" dc:"角色"`
	EnableStatus     uint   `json:"enableStatus" dc:"状态,1-有效，0-无效"`
	EnableStatusName string `json:"enableStatusName" dc:"状态名称"`
	CreatedUserName  string `json:"createdUserName" dc:"创建人"`
	CreatedTime      string `json:"createdTime" dc:"创建时间"`
	UpdatedTime      string `json:"updatedTime" dc:"修改时间"`
	UpdatedUserName  string `json:"updatedUserName" dc:"修改人"`
}

type ListUserReq struct {
	g.Meta       `path:"/list" method:"post"`
	OrgName      string `json:"orgName" dc:"机构名称，模糊搜索"`
	UserName     string `json:"userName" dc:"成员账号，模糊搜索"`
	NickName     string `json:"nickName" dc:"成员昵称，模糊搜索"`
	EnableStatus int    `json:"enableStatus"  d:"-1" dc:"有效状态：1-有效，0-无效，（-1）-全部"`
	common.CommonPaginationReq
}

type ListUserRes struct {
	Detail []*GetUserRes `json:"detail" description:"列表"`
	Total  int64         `json:"total" description:"数据总数"`
}

type SaveUserReq struct {
	g.Meta       `path:"/save" method:"post"`
	UserId       uint   `json:"userId"  dc:"账号Id"`
	OrgId        uint   `json:"orgId" d:"3" dc:"机构Id"`
	UserName     string `json:"userName"  v:"required#用户名必填" dc:"登陆账号"`
	Password     string `json:"password"  dc:"密码"`
	NickName     string `json:"nickName" v:"" dc:"姓名"` // 姓名
	EnableStatus uint   `json:"enableStatus" d:"1" dc:"有效状态：1-有效，0-无效"`
	pwdSalt      string
	operatorId   uint
}

func (s *SaveUserReq) SetOperatorId(operatorId uint) {
	s.operatorId = operatorId
}
func (s *SaveUserReq) GetOperatorId() uint {
	return s.operatorId
}

func (s *SaveUserReq) SetPwdSalt(salt string) {
	s.pwdSalt = salt
}
func (s *SaveUserReq) GetPwdSalt() string {
	return s.pwdSalt
}

type SaveUserRes struct {
	UserId uint `json:"userId" dc:"用户ID"`
}

type DeleteUserReq struct {
	g.Meta     `path:"/delete" method:"post"`
	UserId     uint `json:"userId" v:"required#用户Id必填" dc:"账号Id"`
	operatorId uint
}

func (s *DeleteUserReq) SetOperatorId(operatorId uint) {
	s.operatorId = operatorId
}
func (s *DeleteUserReq) GetOperatorId() uint {
	return s.operatorId
}

type DeleteUserRes struct {
}
type GetUserPermissionReq struct {
	g.Meta `path:"/permission" method:"post"`
	UserId uint `json:"userId" description:"账号Id"`
}
type GetUserPermissionRes struct {
	Detail []*UserPermissionTreeRes `json:"detail" description:"节点"`
}
type UserPermissionTreeRes struct {
	Id        uint   `json:"id" description:"Id"`
	PId       uint   `json:"pId" description:"父Id" d:"0"`
	Title     string `json:"title" description:"显示Label"`
	Remark    string `json:"remark" description:"备注"`
	Spread    bool   `json:"spread" description:"是否展开" d:"true"`
	Checked   bool   `json:"checked" description:"选中状态" d:"false"`
	AuthState uint
	Children  []*UserPermissionTreeRes `json:"children" description:"子节点"`
}

type AuthUserRoleReq struct {
	g.Meta     `path:"/auth" method:"post"`
	UserId     uint   `json:"userId"  dc:"账号Id"`
	RoleIds    []uint `json:"roleIds" v:"" dc:"角色ID"`
	operatorId uint
}

func (s *AuthUserRoleReq) SetOperatorId(operatorId uint) {
	s.operatorId = operatorId
}
func (s *AuthUserRoleReq) GetOperatorId() uint {
	return s.operatorId
}

type AuthUserRoleRes struct {
}
type LoginUserDO struct {
	UserId       uint   // 用户ID
	UserName     string // 用户名
	NickName     string // 昵称
	Password     string // 密码
	PwdSalt      string //密码盐
	EnableStatus int8   // 有效状态：0-无效，1-有效
}
